home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2614.ZIP / TBROWS.ZIP / TTBR3.PRG < prev    next >
Text File  |  1990-10-22  |  3KB  |  133 lines

  1. /*****
  2.  *
  3.  * TTBR3.PRG
  4.  * Third example for TBROWSE class using a database file
  5.  *
  6.  * 19 October 90
  7.  * Luiz Quintela - Nantucket Corp
  8.  *
  9.  * Clipper ttbr3 /N/W/A/B
  10.  * RTLINK FILE ttbr3 PLL base50
  11.  *
  12.  */
  13.  
  14. // Include Header Files
  15. #include "inkey.ch"
  16.  
  17. FUNCTION Main()
  18. LOCAL b, column, nKey
  19. SET SCOREBOARD OFF
  20. SET DATE       BRITISH
  21. SET CONFIRM    ON
  22.  
  23. USE test INDEX test NEW
  24. SETCOLOR( "BG/B,GR+/B,,,BG/N" ); CLS
  25.  
  26. b := TBrowseDB( 2, 2, 20, 48)
  27.  
  28. b:colSep := " │ "
  29. b:headSep := "═╤═"
  30.  
  31. // Include a footer separator character
  32. // using an instance variable named footSep
  33. b:footSep := "═══"
  34.  
  35. // TBColumn objects
  36. column := TBColumnNew( "Field 1", {|| test->fld1} )
  37. // Now you will use the instance variable column:footing to
  38. // tell user this is the first column in the browse display
  39. column:footing := "First"
  40. b:addColumn( column )
  41. column := TBColumnNew( "Field 2", {|| test->fld2} )
  42. b:addColumn( column )
  43. column := TBColumnNew( "Field 3", {|| test->fld3} )
  44. b:addColumn( column )
  45. column := TBColumnNew( "Field 4", {|| test->fld4} )
  46. b:addColumn( column )
  47. column := TBColumnNew( "Field 5", {|| test->fld5} )
  48. column:footing := "Last"
  49. b:addColumn( column )
  50.  
  51. WHILE .T.
  52.  
  53.    // Stabilization
  54.    WHILE ( !b:stabilize() )
  55.       nKey := InKey()
  56.       IF ( nKey != 0 )
  57.          EXIT // abort if a key is waiting
  58.  
  59.       ENDIF
  60.  
  61.    END
  62.  
  63.    IF ( b:stable )
  64.       // Is always a good idea tell the user about end or 
  65.       // beginning of file
  66.       // b:hitTop contais a .T. if an attempt was made 
  67.       // to navigate beyond the beginning of data source
  68.       // b:hitBottom contais a .T. if an attempt was made 
  69.       // to navigate beyond the end of data source
  70.  
  71.       IF ( b:hitTop .OR. b:hitBottom )
  72.           TONE(87.3,1)
  73.          TONE(40,3.5)
  74.  
  75.       ENDIF
  76.  
  77.       // everything's done; just wait for a key
  78.       nKey := INKEY(0)         
  79.  
  80.    ENDIF
  81.  
  82.    // Process key
  83.     IF ( nKey == K_DOWN )
  84.       b:down()
  85.  
  86.    ELSEIF ( nKey == K_UP )
  87.       b:up()
  88.  
  89.    ELSEIF ( nKey == K_PGDN )
  90.       b:pageDown()
  91.  
  92.    ELSEIF ( nKey == K_PGUP )
  93.       b:pageUp()
  94.  
  95.    ELSEIF ( nKey == K_CTRL_PGUP )
  96.       b:goTop()
  97.  
  98.    ELSEIF ( nKey == K_CTRL_PGDN )
  99.       b:goBottom()
  100.  
  101.    ELSEIF ( nKey == K_RIGHT )
  102.       b:right()
  103.  
  104.    ELSEIF ( nKey == K_LEFT )
  105.       b:left()
  106.  
  107.    ELSEIF ( nKey == K_HOME )
  108.       b:home()
  109.  
  110.    ELSEIF ( nKey == K_END )
  111.       b:end()
  112.  
  113.    ELSEIF ( nKey == K_CTRL_LEFT )
  114.       b:panLeft()
  115.  
  116.    ELSEIF ( nKey == K_CTRL_RIGHT )
  117.       b:panRight()
  118.  
  119.    ELSEIF ( nKey == K_CTRL_HOME )
  120.       b:panHome()
  121.  
  122.    ELSEIF ( nKey == K_CTRL_END )
  123.       b:panEnd()
  124.  
  125.    ELSEIF ( nKey == K_ESC )
  126.         CLS; QUIT
  127.  
  128.     ENDIF
  129.  
  130. END
  131.  
  132. /* EOF - TTBR3.PRG */
  133.